package com.vs.myemc_gms_main.controller;

import com.baomidou.mybatisplus.extension.toolkit.Db;
import com.vs.myemc_gms_main.service.UserService;
import com.vs.pojo.Result;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.vs.pojo.User;

/**
 * <p>
 * 用户表 前端控制器
 * </p>
 *
 * @author velvetshiki
 * @since 2024-07-30
 */
@RestController
@RequestMapping("/user")
@Slf4j
public class UserController {
    @Autowired
    private UserService userService;

    @PostMapping("/login")
    public Result userLogin(@RequestBody User user) {
        return Result.success("登录成功", userService.loginService(user));
    }

    @GetMapping
    public Result getUsers() {
        return Result.success("查询成功", Db.lambdaQuery(User.class).list());
    }
}
